package com.deng.springboot.demo.web.config;

import com.deng.springboot.demo.web.interceptor.CommonInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 邓力宾
 * @date 2020/3/1114:31
 * @Description:
 */
@SpringBootConfiguration
public class WebMvcConfig implements WebMvcConfigurer {

    private CommonInterceptor commonInterceptor;
    @Autowired
    public void setCommonInterceptor(CommonInterceptor commonInterceptor){
        this.commonInterceptor = commonInterceptor;
    }
    /**
     * 添加拦截器 设置拦截规则
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(commonInterceptor).addPathPatterns("/**");
    }
}
